//
//  UIStandardNameValueLabel.m
//  vhECGTools
//
//  Created by jia yu on 2022/7/12.
//

#import "UIStandardNameValueLabel.h"
#import <vhECGTools/vhECGTools.h>

@interface UIStandardNameValueLabel(){
    float screenScale;
    float space;
}
@end

@implementation UIStandardNameValueLabel
@synthesize nameLabel;
@synthesize valueLabel;
@synthesize string;


-(void)setString:(NSString *)_string{
    string = _string;
    CGSize size = [nameLabel.text sizeWithAttributes:@{NSFontAttributeName:nameLabel.font}];
    [nameLabel setFrame:CGRectMake(0.f, 0.f, size.width + space, self.frame.size.height)];
    [valueLabel setFrame:CGRectMake(size.width+space, 0.f, self.frame.size.width-size.width-space, self.frame.size.height)];
    valueLabel.text = string;
    return;
}

-(id)initWithFrame:(CGRect)frame scale:(float)scale{
    self = [super initWithFrame:frame];
    if (self){
        screenScale = scale;
        space = 10.f * scale;
        self.backgroundColor = [UIColor clearColor];
        nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.f, 0.f, frame.size.width/2.f, frame.size.height)];
        nameLabel.textColor = [vhECGTools colorFromHEXString:@"606972"];
        nameLabel.backgroundColor = [UIColor clearColor];
        nameLabel.textAlignment = NSTextAlignmentLeft;
        nameLabel.font = [UIFont fontWithName:@"PingFangSC-Thin" size:34.f * scale];
        nameLabel.text = @"Name:";
        [self addSubview:nameLabel];
        
        valueLabel = [[UILabel alloc] initWithFrame:CGRectMake(frame.size.width/2.f, 0.f, frame.size.width/2.f, frame.size.height)];
        valueLabel.textColor = [vhECGTools colorFromHEXString:@"294559"];
        valueLabel.backgroundColor = [UIColor clearColor];
        valueLabel.textAlignment = NSTextAlignmentLeft;
        valueLabel.font = [UIFont fontWithName:@"PingFangSC-Thin" size:34.f * scale];
        valueLabel.text = @"Value";
        [self addSubview:valueLabel];
    }
    return self;
}

-(id)initWithFrame:(CGRect)frame{
    NSLog(@"-(id)initWithFrame:(CGRect)frame sacle:(float)scale");
    return nil;
}

@end
